package com.mlnx.web.data.controller;


import com.alibaba.fastjson.JSON;
import com.mlnx.data.pojo.form.KangTaiForm;
import com.mlnx.data.pojo.vo.BpKangTaiVo;
import com.mlnx.data.service.WaiBuBpService;

import org.shan.spring.base.BaseController;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;

/**
 * Created by amanda.shan on 2017/10/26.
 */
@Api(value = "康泰血压数据接口", tags={"康泰血压数据接口"})
@RestController
@RequestMapping("/mlnx_data/kangtai")
public class KangTaiController extends BaseController {

    @Autowired
    private WaiBuBpService waiBuBpService;

    @ApiOperation(value = "上传血压数据", notes = "")
    @RequestMapping(value = "/sendbp", method = {RequestMethod.GET, RequestMethod.POST})
    public BpKangTaiVo sendZhengKangBpData(String threeJsonData) {

        try {
            KangTaiForm kangTaiForm = JSON.parseObject(threeJsonData, KangTaiForm.class);
            return waiBuBpService.saveKangTaiBp(kangTaiForm);
        } catch (Exception e) {

            BpKangTaiVo bpKangTaiVo = new BpKangTaiVo();
            bpKangTaiVo.setCode(BpKangTaiVo.RE_SEND);
            bpKangTaiVo.setMsg("数据格式异常");
            return bpKangTaiVo;
        }
    }
}
